/*
               File: C38
        Description: Conversion for table MMFAC10
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 18 de Junio de 2010 12:37:35.44
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c38 extends GXProcedure
{
   public c38( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c38.class ), "" );
   }

   public c38( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C382 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A311FacUUM = C382_A311FacUUM[0] ;
         A310FacHUM = C382_A310FacHUM[0] ;
         A309FacFUM = C382_A309FacFUM[0] ;
         A308FacUCR = C382_A308FacUCR[0] ;
         A307FacHCR = C382_A307FacHCR[0] ;
         A306FacFCR = C382_A306FacFCR[0] ;
         A312FacNro = C382_A312FacNro[0] ;
         A305FacPlz = C382_A305FacPlz[0] ;
         A304FacDia = C382_A304FacDia[0] ;
         A303CndPag = C382_A303CndPag[0] ;
         A302FacCod = C382_A302FacCod[0] ;
         A35PrsCod = C382_A35PrsCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0038

         */
         AV2PrsCod = A35PrsCod ;
         AV3CliCod = 0 ;
         AV4FacCod = A302FacCod ;
         if ( C382_n303CndPag[0] )
         {
            AV5CndPagC = 0 ;
         }
         else
         {
            AV5CndPagC = A303CndPag ;
         }
         if ( C382_n304FacDia[0] )
         {
            AV6FacDiaP = 0 ;
         }
         else
         {
            AV6FacDiaP = A304FacDia ;
         }
         if ( C382_n305FacPlz[0] )
         {
            AV7FacPlz = 0 ;
         }
         else
         {
            AV7FacPlz = A305FacPlz ;
         }
         if ( C382_n312FacNro[0] )
         {
            AV8FacNroC = "" ;
         }
         else
         {
            AV8FacNroC = A312FacNro ;
         }
         if ( C382_n306FacFCR[0] )
         {
            AV9FacFCR = GXutil.nullDate() ;
         }
         else
         {
            AV9FacFCR = A306FacFCR ;
         }
         if ( C382_n307FacHCR[0] )
         {
            AV10FacHCR = "" ;
         }
         else
         {
            AV10FacHCR = A307FacHCR ;
         }
         if ( C382_n308FacUCR[0] )
         {
            AV11FacUCR = "" ;
         }
         else
         {
            AV11FacUCR = A308FacUCR ;
         }
         if ( C382_n309FacFUM[0] )
         {
            AV12FacFUM = GXutil.nullDate() ;
         }
         else
         {
            AV12FacFUM = A309FacFUM ;
         }
         if ( C382_n310FacHUM[0] )
         {
            AV13FacHUM = "" ;
         }
         else
         {
            AV13FacHUM = A310FacHUM ;
         }
         if ( C382_n311FacUUM[0] )
         {
            AV14FacUUM = "" ;
         }
         else
         {
            AV14FacUUM = A311FacUUM ;
         }
         /* Using cursor C383 */
         pr_default.execute(1, new Object[] {AV2PrsCod, new Short(AV3CliCod), new Short(AV4FacCod), new Short(AV5CndPagC), new Short(AV6FacDiaP), new Short(AV7FacPlz), AV8FacNroC, AV9FacFCR, AV10FacHCR, AV11FacUCR, AV12FacFUM, AV13FacHUM, AV14FacUUM});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C382_A311FacUUM = new String[] {""} ;
      C382_A310FacHUM = new String[] {""} ;
      C382_A309FacFUM = new java.util.Date[] {GXutil.nullDate()} ;
      C382_A308FacUCR = new String[] {""} ;
      C382_A307FacHCR = new String[] {""} ;
      C382_A306FacFCR = new java.util.Date[] {GXutil.nullDate()} ;
      C382_A312FacNro = new String[] {""} ;
      C382_A305FacPlz = new short[1] ;
      C382_A304FacDia = new short[1] ;
      C382_A303CndPag = new short[1] ;
      C382_A302FacCod = new short[1] ;
      C382_A35PrsCod = new String[] {""} ;
      A311FacUUM = "" ;
      A310FacHUM = "" ;
      A309FacFUM = GXutil.nullDate() ;
      A308FacUCR = "" ;
      A307FacHCR = "" ;
      A306FacFCR = GXutil.nullDate() ;
      A312FacNro = "" ;
      A305FacPlz = 0 ;
      A304FacDia = 0 ;
      A303CndPag = 0 ;
      A302FacCod = 0 ;
      A35PrsCod = "" ;
      GIGXA0038 = 0 ;
      AV2PrsCod = "" ;
      AV3CliCod = 0 ;
      AV4FacCod = 0 ;
      C382_n303CndPag = new boolean[] {false} ;
      AV5CndPagC = 0 ;
      C382_n304FacDia = new boolean[] {false} ;
      AV6FacDiaP = 0 ;
      C382_n305FacPlz = new boolean[] {false} ;
      AV7FacPlz = 0 ;
      C382_n312FacNro = new boolean[] {false} ;
      AV8FacNroC = "" ;
      C382_n306FacFCR = new boolean[] {false} ;
      AV9FacFCR = GXutil.nullDate() ;
      C382_n307FacHCR = new boolean[] {false} ;
      AV10FacHCR = "" ;
      C382_n308FacUCR = new boolean[] {false} ;
      AV11FacUCR = "" ;
      C382_n309FacFUM = new boolean[] {false} ;
      AV12FacFUM = GXutil.nullDate() ;
      C382_n310FacHUM = new boolean[] {false} ;
      AV13FacHUM = "" ;
      C382_n311FacUUM = new boolean[] {false} ;
      AV14FacUUM = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c38__default(),
         new Object[] {
             new Object[] {
            C382_A311FacUUM, C382_n311FacUUM, C382_A310FacHUM, C382_n310FacHUM, C382_A309FacFUM, C382_n309FacFUM, C382_A308FacUCR, C382_n308FacUCR, C382_A307FacHCR, C382_n307FacHCR,
            C382_A306FacFCR, C382_n306FacFCR, C382_A312FacNro, C382_n312FacNro, C382_A305FacPlz, C382_n305FacPlz, C382_A304FacDia, C382_n304FacDia, C382_A303CndPag, C382_n303CndPag,
            C382_A302FacCod, C382_A35PrsCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A305FacPlz ;
   private short A304FacDia ;
   private short A303CndPag ;
   private short A302FacCod ;
   private short AV3CliCod ;
   private short AV4FacCod ;
   private short AV5CndPagC ;
   private short AV6FacDiaP ;
   private short AV7FacPlz ;
   private short Gx_err ;
   private int GIGXA0038 ;
   private String A311FacUUM ;
   private String A310FacHUM ;
   private String A308FacUCR ;
   private String A307FacHCR ;
   private String A312FacNro ;
   private String A35PrsCod ;
   private String AV2PrsCod ;
   private String AV8FacNroC ;
   private String AV10FacHCR ;
   private String AV11FacUCR ;
   private String AV13FacHUM ;
   private String AV14FacUUM ;
   private String Gx_emsg ;
   private java.util.Date A309FacFUM ;
   private java.util.Date A306FacFCR ;
   private java.util.Date AV9FacFCR ;
   private java.util.Date AV12FacFUM ;
   private IDataStoreProvider pr_default ;
   private String[] C382_A311FacUUM ;
   private String[] C382_A310FacHUM ;
   private java.util.Date[] C382_A309FacFUM ;
   private String[] C382_A308FacUCR ;
   private String[] C382_A307FacHCR ;
   private java.util.Date[] C382_A306FacFCR ;
   private String[] C382_A312FacNro ;
   private short[] C382_A305FacPlz ;
   private short[] C382_A304FacDia ;
   private short[] C382_A303CndPag ;
   private short[] C382_A302FacCod ;
   private String[] C382_A35PrsCod ;
   private boolean[] C382_n303CndPag ;
   private boolean[] C382_n304FacDia ;
   private boolean[] C382_n305FacPlz ;
   private boolean[] C382_n312FacNro ;
   private boolean[] C382_n306FacFCR ;
   private boolean[] C382_n307FacHCR ;
   private boolean[] C382_n308FacUCR ;
   private boolean[] C382_n309FacFUM ;
   private boolean[] C382_n310FacHUM ;
   private boolean[] C382_n311FacUUM ;
}

final class c38__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C382", "SELECT [FacUUM], [FacHUM], [FacFUM], [FacUCR], [FacHCR], [FacFCR], [FacNroCon], [FacPlz], [FacDiaPag], [CndPagCod], [FacCod], [PrsCod] FROM [MMFAC10] WITH (NOLOCK) ORDER BY [PrsCod], [FacCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C383", "INSERT INTO [GXA0038] ([PrsCod], [CliCod], [FacCod], [CndPagCod], [FacDiaPag], [FacPlz], [FacNroCon], [FacFCR], [FacHCR], [FacUCR], [FacFUM], [FacHUM], [FacUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 8) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[4])[0] = rslt.getGXDate(3) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 10) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 8) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((java.util.Date[]) buf[10])[0] = rslt.getGXDate(6) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 20) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((short[]) buf[14])[0] = rslt.getShort(8) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((short[]) buf[16])[0] = rslt.getShort(9) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((short[]) buf[18])[0] = rslt.getShort(10) ;
               ((boolean[]) buf[19])[0] = rslt.wasNull();
               ((short[]) buf[20])[0] = rslt.getShort(11) ;
               ((String[]) buf[21])[0] = rslt.getString(12, 10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setShort(2, ((Short) parms[1]).shortValue());
               stmt.setShort(3, ((Short) parms[2]).shortValue());
               stmt.setShort(4, ((Short) parms[3]).shortValue());
               stmt.setShort(5, ((Short) parms[4]).shortValue());
               stmt.setShort(6, ((Short) parms[5]).shortValue());
               stmt.setString(7, (String)parms[6], 20);
               stmt.setDate(8, (java.util.Date)parms[7]);
               stmt.setString(9, (String)parms[8], 8);
               stmt.setString(10, (String)parms[9], 10);
               stmt.setDate(11, (java.util.Date)parms[10]);
               stmt.setString(12, (String)parms[11], 8);
               stmt.setString(13, (String)parms[12], 10);
               break;
      }
   }

}

